package game.frame;

import com.lovo.netCRM.component.LovoButton;
import game.utils.FileUtils;

import javax.swing.*;
import java.awt.*;

/**
 * @author liuyulai
 * Created with IntelliJ IDEA.
 * Date: 21.5.8
 * Time: 17:25
 * Description: 失败界面
 */
public class LoseFrame extends JFrame {
    private LovoButton lb = new LovoButton("再来一局", 140, 200, this);

    private LovoButton lb2 = new LovoButton("查看排行榜", 140, 230, this);


    public LoseFrame() {
        JLabel jlImg = new JLabel();
        Image img = new ImageIcon("img/deathFrame.png").getImage();
        img = img.getScaledInstance(400, 400, 1);
        jlImg.setIcon(new ImageIcon(img));
        this.add(jlImg);
        this.setSize(400, 400);
        this.setVisible(true);
        this.setLayout(null);
        init();
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        this.setLocationRelativeTo(null);
    }

    private void init() {
        lb.addActionListener(e -> {
            this.dispose();
//            BackgroundMaps.mapX = 0;
            MainFrame.sp = 0;
            MainFrame.playerExp = 0;
            MainFrame.isPass = false;
            MainFrame.flag = true;
            MainFrame.gamerNum = 5;
            new MainFrame();
        });

        lb2.addActionListener(e -> {
            FileUtils.readPlayerList();
            this.dispose();
            new Leaderboard();
        });
    }

//    public static void main(String[] args) {
//        new LoseFrame();
//    }

}
